﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using easywork.Utils;

namespace OneBarCode
{
    public partial class FrmHistory : Form
    {
        public FrmHistory()
        {
            InitializeComponent();
        }

        private void btnSearch_Click(object sender, EventArgs e)
        {
            string strMac = textBox1.Text.Trim();
            string strsql = string.Empty;
            if (combStatus.SelectedIndex==0)//超声波前
            {
                strsql = string.Format("select * from HistoryData where Mac like '%{0}%'", strMac);
            }
            else//超声波后
            {
                strsql = string.Format("select * from HistoryData4After where Mac like '%{0}%'", strMac);
            }
            
            //if (!string.IsNullOrEmpty(combStatus.Text))
            //{
            //    strsql = string.Format("select * from HistoryData where Mac like '%{0}%' and Status='{1}'", strMac,combStatus.Text);// 
            //}
            DataTable dt=DataBaseManager.ExecDataSet(strsql).Tables[0];
            dataGridView1.DataSource = dt;
            //dataGridView1.Columns[""].
        }

        private void dataGridView1_RowStateChanged(object sender, DataGridViewRowStateChangedEventArgs e)
        {
            e.Row.HeaderCell.Value = string.Format("{0}", e.Row.Index + 1);
        }

        private void FrmHistory_Load(object sender, EventArgs e)
        {
            //this.combStatus.Items.Add("");
            this.combStatus.Items.Add("超声波前");
            this.combStatus.Items.Add("超声波后");
            this.combStatus.SelectedIndex = 0;
        }
    }
}
